﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Logging="clr-namespace:Microsoft.Practices.EnterpriseLibrary.Configuration.Design.ViewModel.BlockSpecifics.Logging"
    xmlns:Controls="clr-namespace:Microsoft.Practices.EnterpriseLibrary.Configuration.Design.Controls">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/Microsoft.Practices.EnterpriseLibrary.Configuration.DesignTime;component/Resources/ViewModelDataTemplates.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <DataTemplate DataType="{x:Type Logging:MaskedPasswordBindable}">
        <Grid HorizontalAlignment="Stretch">
            <Border BorderBrush="Red"
						BorderThickness="1"
						Margin="-1"
						x:Name="ErrorAdorner"
						Visibility="Collapsed" />

            <Controls:MaskedPasswordTextBox
                        Validation.ErrorTemplate="{x:Null}"
                        x:Name="valueTextBox"
                        Style="{StaticResource BindablePropertyStyle}"
                        AutomationProperties.Name="{Binding DisplayName}"
                        UnsecuredPassword="{Binding BindableValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=true}" />
        </Grid>
        <DataTemplate.Triggers>
            <Trigger Property="Validation.HasError" Value="true" SourceName="valueTextBox">
                <Setter Property="Visibility"
						Value="Visible"
						TargetName="ErrorAdorner" />
            </Trigger>
            <DataTrigger Binding="{Binding ReadOnly}" Value="true">
                <Setter TargetName="valueTextBox" Property="IsEnabled" Value="false" />
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>
</ResourceDictionary>